package com.emcom.gotour.mvc.view;

import java.io.Serializable;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.springframework.context.MessageSource;

import com.emcom.gotour.mvc.message.PagingMessage;

public class PagingView implements Comparable<Object>, Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 398581582758875764L;
	private String first;
	private String last;
	private String previous;
	private String next;
	private String to;
	private String size;
	public PagingView() {
	}
	public PagingView(HttpServletRequest request, MessageSource messageSource) {
		this.first = PagingMessage.FIRST.value(request, messageSource);
		this.last = PagingMessage.LAST.value(request, messageSource);
		this.previous = PagingMessage.PREVIOUS.value(request, messageSource);
		this.next = PagingMessage.NEXT.value(request, messageSource);
		this.to = PagingMessage.TO.value(request, messageSource);
		this.size = PagingMessage.SIZE.value(request, messageSource);
	}
	public String getFirst() {
		return first;
	}
	public void setFirst(String first) {
		this.first = first;
	}
	public String getLast() {
		return last;
	}
	public void setLast(String last) {
		this.last = last;
	}
	public String getPrevious() {
		return previous;
	}
	public void setPrevious(String previous) {
		this.previous = previous;
	}
	public String getNext() {
		return next;
	}
	public void setNext(String next) {
		this.next = next;
	}
	public String getTo() {
		return to;
	}
	public void setTo(String to) {
		this.to = to;
	}
	public String getSize() {
		return size;
	}
	public void setSize(String size) {
		this.size = size;
	}
	/**
	 * @see java.lang.Comparable#compareTo(Object)
	 */
	public int compareTo(Object object) {
		PagingView myClass = (PagingView) object;
		return new CompareToBuilder().append(this.to, myClass.to).append(
				this.previous, myClass.previous)
				.append(this.last, myClass.last)
				.append(this.next, myClass.next).append(this.first,
						myClass.first).append(this.size, myClass.size)
				.toComparison();
	}
	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof PagingView)) {
			return false;
		}
		PagingView rhs = (PagingView) object;
		return new EqualsBuilder().appendSuper(super.equals(object)).append(
				this.to, rhs.to).append(this.previous, rhs.previous).append(
				this.last, rhs.last).append(this.next, rhs.next).append(
				this.first, rhs.first).append(this.size, rhs.size).isEquals();
	}
	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-606656837, -1238594563).appendSuper(
				super.hashCode()).append(this.to).append(this.previous).append(
				this.last).append(this.next).append(this.first).append(
				this.size).toHashCode();
	}
	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this).append("previous", this.previous)
				.append("to", this.to).append("next", this.next).append("last",
						this.last).append("size", this.size).append("first",
						this.first).toString();
	}
}
